package com.djpeng.du.simple_pinyin;

import java.util.Arrays;

/**
 * Created by dujp on 15/5/2.
 * djpeng.du@gmail.com
 */
public class Spy implements SimplePinyin {
    private static Table table;

    private Spy(){
    }

    public void init() throws Exception{
        table = ResourceHelper.readResource();
    }

    public String[] convertFrom(char chinese) {
        String code = codeCn(chinese);
        return table.getValue(code);
    }

    private String codeCn(char chinese){
        int codePoint;
        codePoint = chinese;
        return Integer.toHexString(codePoint).toUpperCase();
    }

    public static void main(String[] args) {
        Spy spy = new Spy();
        try {
            spy.init();
        } catch (Exception e) {
            e.printStackTrace();
        }
        String[] results = spy.convertFrom('上');
        System.out.println(Arrays.asList(results));
    }
}
